package com.gomore.opple.module.addbankcard;

import android.view.KeyEvent;

import com.gomore.opple.R;
import com.gomore.opple.module.BaseActivity;

import javax.inject.Inject;

/**
 * Created by asus on 2017/5/9.
 */
public class AddBankCardActivity extends BaseActivity {
    @Inject
    AddBankCardPresenter addBankCardPresenter;

    private AddBankCardFragment addBankCardFragment;

    @Override
    protected void initalizeViewData() {
        super.initalizeViewData();
    }

    @Override
    protected void initalizeViews() {
        if (addBankCardFragment == null) {
            addBankCardFragment = AddBankCardFragment.getInstance();
            replaceFragment(addBankCardFragment, false, "add_bank_card_view");
        }
    }

    @Override
    protected void initializeDependencyInjector() {
        DaggerAddBankCardComponent.builder()
                .dataRepositoryComponent(getRepositoryComponent())
                .addBankCardPresenterModule((new AddBankCardPresenterModule(addBankCardFragment)))
                .build()
                .inject(this);
    }

    @Override
    protected int getLayoutView() {
        return R.layout.activity_add_bank_card;
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK
                && event.getAction() == KeyEvent.ACTION_DOWN) {
            addBankCardFragment.showPage();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
